<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<style type="text/css">
			*{
				margin: 0;
				padding: 0;
			}
			img{
				width: 150px;
				height: 150px;
			}
			.box{
				/*水平居中*/
				text-align: center;
				padding-top: 30px;
				padding-bottom: 30px;
				background-color: rgba(99,134,177,0.6);
			}
			body{
				background-image: url("images/1.jpg");
				background-size: cover; /* 图像将铺满整个元素 */
				background-repeat: no-repeat;/* 防止图像平铺 */
			}
		</style>
	</head>
	<!-- style="background-image: ;" -->
	<body style="">
		<div class="box">
			<img src="images/1.jpg"/>
			<img src="images/2.jpg"/>
			<img src="images/3.jpg"/>
			<img src="images/4.jpg"/>
			<img src="images/5.jpg"/>
		</div>
		
		<script type="text/javascript">
			window.onload = function () {
				var images = document.getElementsByTagName('img');
				for (var i = 0; i < images.length; i++) {
					images[i].onclick = function () {
						//this 代表当前点击对象
						var imageSrc = this.src;
						//document.body.style.backgroundImage = 'url("images/2.jpg")';
						document.body.style.backgroundImage = 'url("'+imageSrc+'")';
					}
				}
			}
		</script>
	</body>
</html>
